package com.gzu.finalwork.admin.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.gzu.finalwork.admin.service.AdCourierService;
import com.gzu.finalwork.entity.courier.Couriers;
import com.gzu.finalwork.common.utils.AjaxResult;
import com.gzu.finalwork.common.utils.SensitiveOperation;

@RestController
@RequestMapping("/admin")
public class AdCourierController {
    @Autowired
    private AdCourierService adCourierService;

    // 获取所有快递员
    @GetMapping("/couriers")
    public Object getCouriers() {
        return AjaxResult.success(adCourierService.getCouriers());
    }

    // 添加快递员
    @PostMapping("/couriers")
    public Object addCourier(@RequestBody Couriers courier) {
        adCourierService.addCourier(courier);
        return AjaxResult.success("添加成功");
    }

    // 修改快递员
    @PutMapping("/couriers/{id}")
    public Object updateCourier(@PathVariable Integer id, @RequestBody Couriers courier) {
        adCourierService.updateCourier(id, courier);
        return AjaxResult.success("修改成功");
    }

    // 删除快递员
    @SensitiveOperation(
        value = "删除配送员", 
        operationType = "删除操作"
    )
    @DeleteMapping("/couriers/{id}")
    public Object deleteCourier(@PathVariable Integer id) {
        adCourierService.deleteCourier(id);
        return AjaxResult.success("删除成功");
    }
}
